package com.huawei.appgallery.appcomment.ui.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.InflateException;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.ProgressBar;
import android.widget.RatingBar;
import android.widget.TextView;
import com.huawei.appgallery.appcomment.impl.bean.GetCommentResBean.RatingDst;
import java.util.List;
import o.azb;
import o.bcb;
import o.bcg.d;
import o.bcg.e;
import o.bcg.f;
import o.bcg.h;
import o.ber;
import o.cdn;
import o.cdo;
import o.cgy;

public class AppScoreView extends LinearLayout {
    private Context ˋ;
    private View ॱ;

    public AppScoreView(Context context) {
        this(context, null);
    }

    public AppScoreView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        this.ˋ = context;
        try {
            this.ॱ = ((LayoutInflater) context.getSystemService("layout_inflater")).inflate(d.ʽ, this, true);
            azb.ˏ(this.ॱ);
        } catch (InflateException e) {
            bcb.ˋ.ˊ("DetailScoreView", "inflate xml fail, error = " + e.toString());
        }
    }

    public void setData(float f, float f2, int i, List<RatingDst> list) {
        if (this.ॱ != null) {
            ˎ();
            ˊ(f, f2, i);
            ˋ();
            ˎ(i, list);
        }
    }

    private void ˎ(int i, List<RatingDst> list) {
        ProgressBar progressBar = (ProgressBar) this.ॱ.findViewById(e.ͺˏ);
        progressBar.setProgress(0);
        ProgressBar progressBar2 = (ProgressBar) this.ॱ.findViewById(e.ͺˎ);
        progressBar2.setProgress(0);
        ProgressBar progressBar3 = (ProgressBar) this.ॱ.findViewById(e.ॱˌ);
        progressBar3.setProgress(0);
        ProgressBar progressBar4 = (ProgressBar) this.ॱ.findViewById(e.ॱᶥ);
        progressBar4.setProgress(0);
        ProgressBar progressBar5 = (ProgressBar) this.ॱ.findViewById(e.ॱʿ);
        progressBar5.setProgress(0);
        if (list != null) {
            for (RatingDst ratingDst : list) {
                int ˋ;
                if (i > 0) {
                    ˋ = (int) ((((float) ratingDst.ˋ()) / ((float) i)) * 100.0f);
                } else {
                    ˋ = 0;
                }
                switch (ratingDst.ॱ()) {
                    case 1:
                        progressBar5.setProgress(ˋ);
                        break;
                    case 2:
                        progressBar4.setProgress(ˋ);
                        break;
                    case 3:
                        progressBar3.setProgress(ˋ);
                        break;
                    case 4:
                        progressBar2.setProgress(ˋ);
                        break;
                    case 5:
                        progressBar.setProgress(ˋ);
                        break;
                    default:
                        break;
                }
            }
        }
    }

    private void ˊ(float f, float f2, int i) {
        TextView textView = (TextView) this.ॱ.findViewById(e.ʼ);
        RatingBar ratingBar = (RatingBar) this.ॱ.findViewById(e.ˋʽ);
        TextView textView2 = (TextView) this.ॱ.findViewById(e.ॱﾞ);
        if (Float.compare(f2, 0.0f) == 0 && i == 0) {
            textView2.setText(this.ˋ.getString(h.ʹ));
        } else {
            textView2.setText(this.ˋ.getResources().getQuantityString(f.ˋ, i, new Object[]{Integer.valueOf(i)}));
        }
        textView.setText(cgy.ˎ((double) f));
        ratingBar.setRating(f2);
    }

    private void ˋ() {
        TextView textView = (TextView) this.ॱ.findViewById(e.ˊʾ);
        TextView textView2 = (TextView) this.ॱ.findViewById(e.ˉᐝ);
        TextView textView3 = (TextView) this.ॱ.findViewById(e.ㆍॱ);
        TextView textView4 = (TextView) this.ॱ.findViewById(e.ᵔ);
        ((TextView) this.ॱ.findViewById(e.ﹺ)).setText(cgy.ˎ(1.0d));
        textView.setText(cgy.ˎ(2.0d));
        textView2.setText(cgy.ˎ(3.0d));
        textView3.setText(cgy.ˎ(4.0d));
        textView4.setText(cgy.ˎ(5.0d));
    }

    private void ˎ() {
        LinearLayout linearLayout = (LinearLayout) this.ॱ.findViewById(e.ˋʼ);
        if (cdn.ˋ() && ber.ˊ(this.ॱ.getContext())) {
            linearLayout.getLayoutParams().width = cdo.ˎ(this.ॱ.getContext());
        }
    }
}
